FROM python:3.6.6

# 更改系统源
RUN echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" > /etc/apt/sources.list
RUN echo "deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib" >> /etc/apt/sources.list
RUN echo "deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib" >> /etc/apt/sources.list
RUN echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >> /etc/apt/sources.list
RUN echo "deb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib" >> /etc/apt/sources.list
RUN echo "deb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib" >> /etc/apt/sources.list
RUN echo "deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib" >> /etc/apt/sources.list
RUN echo "deb-src http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib" >> /etc/apt/sources.list
RUN apt-get -y update
#MySQL-Python必须得先安装这个库
RUN apt-get install -y libmysqlclient-dev   

RUN mkdir /TopnetDataServerDirectory
#设置工作目录
WORKDIR /TopnetDataServerDirectory
#将当前目录加入到工作目录中
ADD . /TopnetDataServerDirectory
RUN echo "#!/bin/bash" > start.sh
RUN echo "mkdir -p /home/uwsgi/logs/ &&" >> start.sh
RUN echo "touch /home/uwsgi/logs/uwsgi_tdsdserver.log &&" >> start.sh
RUN echo "python manage.py collectstatic --noinput &&" >> start.sh
# TODO 实际部署需要解开下边的注释
# RUN echo "python manage.py migrate &&" >> start.sh
RUN echo "uwsgi TDSD_server.xml" >> start.sh
#install any needed pacakges in requirements.txt，你要把所有需要安装的Python模块加到这文件中。
RUN pip install -i https://pypi.douban.com/simple -r requirements.txt
#对外暴露端口
EXPOSE 8101
#设置环境变量
ENV TDSD=/TopnetDataServerDirectory

